package com.newhis.config;

import com.newhis.ws.TestService;
import com.newhis.ws.impl.TestServiceImpl;
import org.apache.cxf.Bus;
import org.apache.cxf.binding.BindingConfiguration;
import org.apache.cxf.bus.spring.SpringBus;
import org.apache.cxf.interceptor.Interceptor;
import org.apache.cxf.interceptor.LoggingInInterceptor;
import org.apache.cxf.interceptor.LoggingOutInterceptor;
import org.apache.cxf.jaxws.EndpointImpl;
import org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean;
import org.apache.cxf.message.Message;
import org.apache.cxf.transport.servlet.CXFServlet;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.xml.ws.Binding;
import java.util.List;

/**
 * 业务聚合
 *
 * @version [V2.0]
 * @package com.newhis.config;
 * @description:[用一句话描述该文件做什么]
 * @author: [zhuben]
 * @date: [2024-11-01 16:47]
 * @copyright: 2024 echovin.com
 */
@Configuration
public class CxfConfig {

    @Bean(name = Bus.DEFAULT_BUS_ID)
    public SpringBus springBus(){
        return new SpringBus();
    }

    @Bean
    public TestService testService(){
        return new TestServiceImpl();
    }

    @Bean
    public EndpointImpl endpoint(){
        EndpointImpl endpoint = new EndpointImpl(springBus(), testService());
        List<Interceptor<? extends Message>> inInterceptors = endpoint.getInInterceptors();
        inInterceptors.add(new LoggingInInterceptor());
        inInterceptors.add(new WsInterceptor());

        endpoint.getOutInterceptors().add(new LoggingOutInterceptor());
        endpoint.publish("/test");
        return endpoint;
    }
}
